﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="LahendOtsingKisTulem", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(LahendOtsingKisTulem))]
    public class LahendOtsingKisTulemSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ILahendOtsingKisTulem clazz;
        
        public LahendOtsingKisTulemSerializer(ILahendOtsingKisTulem clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.MenetluseObjektID!=null) {
                Writer.WriteStartElement("MenetluseObjektID");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.MenetluseObjektID))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MenetluseNimetus!=null) {
                Writer.WriteStartElement("MenetluseNimetus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MenetluseNimetus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ToimingObjektID!=null) {
                Writer.WriteStartElement("ToimingObjektID");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.ToimingObjektID))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OtsuseKP!=null) {
                Writer.WriteStartElement("OtsuseKP");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.OtsuseKP))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MenetlevAsutusLyhend!=null) {
                Writer.WriteStartElement("MenetlevAsutusLyhend");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MenetlevAsutusLyhend))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.FailObjektID!=null) {
                Writer.WriteStartElement("FailObjektID");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.FailObjektID))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.FailiNimetus!=null) {
                Writer.WriteStartElement("FailiNimetus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.FailiNimetus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Koostaja!=null) {
                Writer.WriteStartElement("Koostaja");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Koostaja))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ToiminguNr!=null) {
                Writer.WriteStartElement("ToiminguNr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ToiminguNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MenetluseNr!=null) {
                Writer.WriteStartElement("MenetluseNr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MenetluseNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OnSalajaneAsi!=null) {
                Writer.WriteStartElement("OnSalajaneAsi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.OnSalajaneAsi))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="MenetluseObjektID") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>LahendOtsingKisTulem>MenetluseObjektID");
                }
                clazz.MenetluseObjektID = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("MenetluseObjektID")).Value;
            }
            if (Reader.LocalName=="MenetluseNimetus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MenetluseNimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("MenetluseNimetus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ToimingObjektID") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>LahendOtsingKisTulem>ToimingObjektID");
                }
                clazz.ToimingObjektID = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("ToimingObjektID")).Value;
            }
            if (Reader.LocalName=="OtsuseKP") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>LahendOtsingKisTulem>OtsuseKP");
                }
                clazz.OtsuseKP = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("OtsuseKP")).Value;
            }
            if (Reader.LocalName=="MenetlevAsutusLyhend") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MenetlevAsutusLyhend = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("MenetlevAsutusLyhend")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="FailObjektID") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>LahendOtsingKisTulem>FailObjektID");
                }
                clazz.FailObjektID = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("FailObjektID")).Value;
            }
            if (Reader.LocalName=="FailiNimetus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.FailiNimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("FailiNimetus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Koostaja") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Koostaja = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Koostaja")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ToiminguNr") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ToiminguNr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ToiminguNr")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="MenetluseNr") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MenetluseNr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("MenetluseNr")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="OnSalajaneAsi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>LahendOtsingKisTulem>OnSalajaneAsi");
                }
                clazz.OnSalajaneAsi = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("OnSalajaneAsi")).Value;
            }
        }
    }
}
